package com.homwee.factory;

import java.util.ArrayList;
import java.util.List;

//zcj 2018-10-31 import com.changhong.inface.net.NetworkSettingUtils;
//zcj 2018-10-31 import com.changhong.inface.net.wifi.WifiAccessPoint;

import com.homwee.tvap.common.ap.ComSettingManager;
import com.homwee.tvap.common.srvfunc.FactorySetting;
import android.app.Activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
//zcj 2018-10-31 import android.os.storage.StorageVolume;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;

public class FactorySelectActivity extends Activity {
	public static Context mContext;
	private ListView mListView;
	private List<String> mDatas = new ArrayList<String>();
	public final String TAG = "zcj";

	ArrayAdapter<String> adapter;
	public int bt_count = 0;

	public ComSettingManager mcomSettingManager;
	public FactorySetting factorySetting;

	private static String[] panelStrings = { "40_SAMSUNG_FHD_100_120",
			"HDMITX_1440_60P", "AU20_T200XW02", "HDMITX_1470_60P",
			"AU32_T315XW03", "HDMITX_2160_24P", "AUO_T420HW09_TCON",
			"HDMITX_480_60P", "DACOUT_1080I_50", "HDMITX_4K1K_60P",
			"DACOUT_1080I_60", "HDMITX_4K2K_25P", "DACOUT_1080P_24",
			"HDMITX_4K2K_30P", "DACOUT_1080P_25", "HDMITX_576_50P",
			"DACOUT_1080P_30", "HDMITX_720_50P", "DACOUT_1080P_50",
			"HDMITX_720_60P", "DACOUT_1080P_60", "HDMITX_VB1_1080_60P",
			"DACOUT_2205P_24", "HDMITX_VB1_4K2K_30P", "DACOUT_4096X2160P_24",
			"HDMITX_VB1_4K2K_60P", "DACOUT_4096X2160P_25", "M190A1",
			"DACOUT_4096X2160P_30", "Panel", "DACOUT_4096X2160P_50",
			"SXGA_AU17_EN05", "DACOUT_4096X2160P_60", "UD_4K2K_Vx1_4lane",
			"DACOUT_480I_60", "UD_CMO4K1K_HSLVDS_10bit_Bypass",
			"DACOUT_480P_60", "UD_CMO4K1K_NikeU", "DACOUT_4K2KP_24",
			"UD_CMO4K1K_URSA", "DACOUT_4K2KP_25", "UD_CMO4K2K_Bypass",
			"DACOUT_4K2KP_30", "UD_CMO4K2K_FRC", "DACOUT_4K2KP_50",
			"UD_CMO4K2K_HSLVDS", "DACOUT_4K2KP_60",
			"UD_CMO4K2K_HSLVDS_10bit_Bypass", "DACOUT_576I_50",
			"UD_CMO4K2K_INX_VB1", "DACOUT_576P_50", "UD_CMO4K2K_NikeU",
			"DACOUT_720P_50", "UD_CMO4K2K_URSA", "DACOUT_720P_60",
			"UD_VB1_16LANE", "FHD_2K1K_Vx1_2lane", "UD_VB1_16LANE_CSOT_URSA",
			"FullHD_CMO216_H1L01", "UD_VB1_2V", "FullHD_CMO216_H1L01_720P",
			"UD_VB1_2V2O", "FullHD_CMO216_H1L01_HSLVDS", "UD_VB1_4LANE",
			"FullHD_CMO216_H1L01_NikeU", "UD_VB1_4V",
			"FullHD_CMO216_H1L01_Rocket", "UD_VB1_4V2O",
			"FullHD_CMO216_H1L01_URSA", "UD_VB1_8LANE",
			"FullHD_CMO216_H1L01_auto_test", "UD_VB1_8LANE_CSOT",
			"FullHD_LG120HZ", "UD_VB1_8LANE_CSOT_120",
			"FullHD_LG420EUF_120HZ_3DPASSIVE", "UD_VB1_8LANE_CSOT_240",
			"FullHD_VB1_2LANE", "UD_VB1_8LANE_CSOT_URSA", "FullHD_VB1_4LANE",
			"UD_VB1_8LANE_CSOT_URSA_PWM_INVERSE", "HDMITX_1080_50I",
			"UD_VB1_8LANE_FHD", "HDMITX_1080_50P", "UD_VB1_8LANE_ISP",
			"HDMITX_1080_60I", "UD_VB1_8LANE_M28DGJ_L30", "HDMITX_1080_60P",
			"WXGA_LG32_LC320EXN", "HDMITX_1440_50P" };

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		mContext = this;
		mcomSettingManager = ComSettingManager.getInstance(this);
		factorySetting = mcomSettingManager.getFactory();
		setContentView(R.layout.menu_information_list);
		initData();
		mListView = (ListView) findViewById(R.id.listInfoView);
		adapter = new ArrayAdapter<String>(mContext,
				R.layout.simple_list_item_2, mDatas);
		mListView.setAdapter(adapter);

		mListView.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				// TODO Auto-generated method stub
				String mSelName = ((TextView) arg1).getText().toString();
				factorySetting.setPanelName(mSelName);
				Intent intent = new Intent();
				intent.putExtra("PANEL_NAME", mSelName); 
				setResult(100, intent);
				
				finish();
			}
		});

		mListView.setSelector(R.drawable.settings_item_selector);
	}

	private void initData() {
		mDatas.clear();
		for (int i = 0; i < panelStrings.length; i++) {
			String name = panelStrings[i];
			Log.v("zcj", "add name =" + name);
			mDatas.add(name);
		}

	}

	public boolean onKeyDown(int keyCode, KeyEvent event) {

		switch (keyCode) {
		case KeyEvent.KEYCODE_3D_MODE:
		case KeyEvent.KEYCODE_SETTINGS:
		case KeyEvent.KEYCODE_MENU:
			this.finish();
			Log.v("KEYCODE_MENU", "KEYCODE_MENU=" + KeyEvent.KEYCODE_MENU);
			return true;
		default:

			break;
		}
		return super.onKeyDown(keyCode, event);

	}

}